Re Squeak to .Net Bridge- This looks interesting... [meta-douglasp]
Return to home page
Comments Loading...
2003-09-14
[Spotted in Clarence Westberg's Radio Weblog>http://radio.weblogs.com/0102279/2003/09/14.html#a1523].

I have a problem with Smalltalk. It is the most flexible language I know of, save Lisp, yet it has one area of it that is not flexible in the slightest: Instance Structure.

To deal in Smalltalk you have to deal in Smalltalk classes and Smalltalk instances. To get around this problem there is DoesNotUnderstand. You then make proxy classes that represent a class in another system, say, .NET or a C struct, then any message sent to your class isn't understood, and it converted in to a call to the external system.

I don't like this. I don't like this one bit. May be I'm dreaming, but why couldn't Smalltalk have a different kind of Class that can represent itself in a customly defined memory structure. We already write all the marshal/unmarshal code for these alternate protocols - so why cannot this be part of the way Smalltalk normally works for it's own classes.

You want a new memory format? subclass InstanceMarshaller and define it on your class. Then you could add Smalltalk methods on top of C structures. You could have SDL and DirectX structures acting as 'real' Smalltalk classes, then make a bunch of ST methods to call the C methods with itself as the pointer in some of their arguments.

In the end it means the system would naturally exist in other peoples domains. Heck you could have java structures in there too and it'd "just work". It would also be an end to the DNU trick mis-use. Leave DNU for the real proxy pattern (like sending messages over a network), not for external structure changes.

At the same token, you should be able to have MemoryPolicies so that these C things don't move around in memory, they stay put. Sure, this means greater memory fragmentation and slower alloc/dealloc for them (just as you would have in C!) but then it's playing by the rules of the other system.

MAKE SMALLTALK THE HUB!

There's no reason why we cannot make Smalltalk play by other peoples rules and stick our rules on top. Trying to make a Smalltalk play IN other peoples rules is near impossible (ever tried playing a thought game of a Smalltalk that re-written in C without a VM?). But why not make the Smalltalk play by their rules a little, instead of our current situation: not at all.

The thing I like about this idea is that it is orthagonal to existing Smalltalk behaviour. Things in ST that subclass off Class play as normal, then along side Class in the Meta hierarchy would be CStructure and JavaClass and DotNetClass... It'd do away with these miriad of .NET bridge frameworks, it'd outclass S# (because you can receive foreign .NET objects and just 'use them') and it'd make for a very extensible system in to the future.

Tell me I'm wrong and nuts? - explain it to me why this is a bad idea please :)

One last thought: Unique memory structures for Classes. Classes that come and go from the system. Having instances without having a defined class for them (have a virtual temporary class). Guess what this means? - structures that aren't "real" can exist and act as first class objects in Smalltalk too - for example, an XML document, who's class is his DTD or XSchema. Try this on for size guys:

{http://www.w3.org/1999/xhtml2} new

Rant over for now.. please comment and let me know what you think.